<html>
<head><meta charset="utf-8"><title>transmute options · project-safe-transmute · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/index.html">project-safe-transmute</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/transmute.20options.html">transmute options</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="203723460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/transmute%20options/near/203723460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/transmute.20options.html#203723460">(Jul 13 2020 at 14:42)</a>:</h4>
<p><span class="user-mention" data-user-id="219211">@Jack Wrenn</span> how would transmute options handle types that have equivalent layouts, ABIs, etc, but only different in that one is Send and the other is not?</p>



<a name="203723959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/transmute%20options/near/203723959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/transmute.20options.html#203723959">(Jul 13 2020 at 14:46)</a>:</h4>
<p>Since transmutation consumes the src value and produces a 'new' of the destination type, I don't believe there's any special interaction with the <code>Send</code> and <code>Sync</code> traits as far as transmuting values goes.</p>



<a name="203724257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/transmute%20options/near/203724257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/transmute.20options.html#203724257">(Jul 13 2020 at 14:48)</a>:</h4>
<p>If you have &amp;T where T: !Sync and you transmute to &amp;U where U: Sync, you could send across threads when you shouldn't be able to</p>



<a name="203724810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/transmute%20options/near/203724810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/transmute.20options.html#203724810">(Jul 13 2020 at 14:52)</a>:</h4>
<p>I'll give this some thought. I don't have an immediate answer as to whether that can lead to unsafety. It sounds like there could be another constraint in the "Requirements on References" section. (<code>UnsafeCell</code> requires special attention; so too might <code>Send</code> and <code>Sync</code>) If so, it might suggest another useful <code>Neglect*</code> option!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>